// pages/staff/detail.js
var app = getApp()
Page({
    data: {
        userid:'',
        page:1,
        res:[],//分页数据
        nomore: false,
        list:[],
        type:''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        const user = wx.getStorageSync('user');
        this.setData({
            userid: user.id,
            type: options.type
          })
        this.getInputDetail();
    },
    getInputDetail:function(){
        var that = this;
        app.util.request({
            url: 'entry/wxapp/getInputDetails',
            data: {
              userid: that.data.userid,
              page: that.data.page,
              opt: that.data.type
            },
            cachetime: 0,
            success: function (res) {
              that.setData({
                res: res.data.data
              })
              var page = that.data.page;
              var list = that.data.list;
              var res = that.data.res;
              if(res.length>0){
                that.setData({
                  list: list.concat(res),
                  page: page + 1,
                })
              }else if(that.data.list.length>0){
                that.setData({
                  nomore: true,
                  res:[]
                })
              }
              //隐藏loading 提示框
              wx.hideLoading();
              //隐藏导航条加载动画
              wx.hideNavigationBarLoading();
              //停止下拉刷新
              wx.stopPullDownRefresh();
            }
          })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
      this.setData({
        list: [],
        nomore: false,
        page: 1
      })
      this.getInputDetail();
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        this.getInputDetail();
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})